package com.mzj.saas.commons;

import java.util.Random;

/**
 *
 * 随机生成一个32位长度的16进制字符串
 *
 * @author zhang_wei
 * @version 1.0.0
 * @Classname GenerateNiceString
 * @Date 2021/4/13 14:05
 * @Created by zhang_wei
 * @since 1.0.0
 */
public class GenerateNiceString {

    /**
     * 常量池
     */
    public static final String[] POOL = new String[]{"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"};

    /**
     * 生成字符串
     * @return 生成的32位长度的16进制字符串
     */
    public static String generateNiceString(){
        StringBuilder sb = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < 32; i++) {
            sb.append(POOL[random.nextInt(POOL.length)]);
        }
        return sb.toString();
    }

    /**
     * 测试一下
     * @param args 参数
     */
    public static void main(String[] args) {
        System.out.println(generateNiceString());
        System.out.println(generateNiceString());
    }
}
